import { Env } from "#Config/base.js"
import appConifg from '#Config/app.js';

// 初始化 环境变量
Env

const env = appConifg.app_env;


export default {
    appenders: {
        console: {
            type: 'console',
            layout: { type: 'pattern', pattern: `[%d{yyyy-MM-dd hh:mm:ss.SSS}] [${env.toUpperCase()}.%p] %m \n` }
        },
        daily: {
            type: 'dateFile',
            filename: 'storage/logs/koa.log',
            pattern: 'yyyy-MM-dd',
            fileNameSep: '-',
            keepFileExt: true,
            alwaysIncludePattern: true,
            numBackups: 2,
            layout: { type: 'pattern', pattern: `[%d{yyyy-MM-dd hh:mm:ss.SSS}] [${env.toUpperCase()}.%p] %m \n` },
            compress: false
        },
        sql: {
            type: 'dateFile',
            filename: 'storage/logs/sql.log',
            pattern: 'yyyy-MM-dd',
            fileNameSep: '-',
            keepFileExt: true,
            alwaysIncludePattern: true,
            numBackups: 2,
            layout: { type: 'pattern', pattern: `[%d{yyyy-MM-dd hh:mm:ss.SSS}] %m \n` },
            compress: false
        }
    },
    categories: {
        default: { appenders: ['daily'], level: 'info' },
        daily: { appenders: ['daily'], level: 'info' },
        all: { appenders: ['console', 'daily'], level: 'info' },
        sql: { appenders: ['sql'], level: 'info' },
    }
}